#include <iostream>
#include <ctime>
#include "threadpool.hpp"
#include "Task.hpp"

int main(){
    srand(time(nullptr));
    //ThreadPool<Task> *tp = new ThreadPool<Task>(5);
    ThreadPool<Task>::GetInstance()->start();

    while(true){
        // 1.构建任务
        int data1 = rand() % 10 + 1;
        int data2 = rand() % 10;
        char op = opers[rand() % opers.size()];
        Task t(data1, data2, op);

        // 2.交给线程池处理
        ThreadPool<Task>::GetInstance()->Push(t);
        std::cout << "main thread push a task: " << t.GetTask() << std::endl;
        sleep(1);
    }

    return 0;
}